files = dir('*.asc');  % lists all .asc files in directory

minl = inf;
dat = cell(1,numel(files));
summaries = cell(1,numel(files));
for i = 1:numel(files)
    [dat{i}, summaries{i}] = rick_read_trace(files(i).name);
    minl  = min(minl, size(dat{i}, 1));
end

mdat = 0;
for i = 1:numel(dat)
    mdat = mdat+dat{i}(1:minl, 2:4);
end

mdat = mdat/numel(dat);